<?php
namespace Admin\Controller;
use Think\Controller;
class UserController extends BaseController {

	public function __construct()	
	{
		parent::__construct();
	}

    public function login(){
        $this->display();
    }

     public function doLogin(){
    	$email = $this->toStr('email');
        $pwd   = $this->toStr('password');
        if(empty($email) || empty($pwd)) {
            $this->error('Email或密码不能为空。', $this->admin_url . '/user/login', 3);
        }
        if($email != 'sq371426@163.com' || $pwd != 'sq371426@163.com') {
            $this->error('Email和密码不匹配。', $this->admin_url . '/user/login', 3);
        }

        session(array('name'=>'chunxiaoyuer','expire'=>time()+3600, 'domain' => '/'));
        session('username', 'sq371426@163.com');
        $this->success('登陆成功。' . session('username'), $this->admin_url . '/Index/index');
    }
}